package cn.tedu.imop.content.dao.repository.impl;

import cn.tedu.imop.common.context.PageContext;
import cn.tedu.imop.common.pojo.PageData;
import cn.tedu.imop.common.utils.PageInfoToPageDataConverter;
import cn.tedu.imop.content.dao.mapper.ArticleMapper;
import cn.tedu.imop.content.dao.repository.ArticleRepository;
import cn.tedu.imop.content.entity.Article;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ArticleRepositoryImpl implements ArticleRepository {
    private final ArticleMapper articleMapper;
    public ArticleRepositoryImpl(ArticleMapper articleMapper) {
        this.articleMapper = articleMapper;
    }
    @Override
    public int insertArticle(Article article) {
        int rows=articleMapper.insert(article);
        return rows;
    }
    @Override
    public PageData<Article> selectArticleList(Article article) {
        PageContext.startPage();
        List<Article> list=articleMapper.selectList(article);
        return PageInfoToPageDataConverter.convert(new PageInfo<>(list));
    }
}
